7.1 Dependencies

Code
library(dplyr)
library(readr)

7.2 Get data

Code
data_unique_id_subset <- read_csv("../data/raw/data_unique_id_subset.csv")
data_age_gender_subset <- read_csv("../data/raw/data_age_gender_subset.csv")
data_amp_summary_subset <- read_csv("../data/raw/data_amp_summary_subset.csv")
data_selfreport_summary_subset <- read_csv("../data/raw/data_selfreport_summary_subset.csv")

nrow(data_unique_id_subset)
[1] 92
Code
nrow(data_age_gender_subset)
[1] 90
Code
nrow(data_amp_summary_subset)
[1] 31
Code
nrow(data_selfreport_summary_subset)
[1] 76

7.3 Practicing joins

Using the data frames below and functions from the _join family, write code to do the following joins.

7.3.1 Practice 1

create ‘data_combined’ by joining data_amp_summary_subset and data_age_gender_subset so that unique_ids in either data frame are retained. which join is this? implement it.

Code
# data_combined <- 

7.3.2 Practice 2

create ‘data_self_reports_and_their_amp_data’ by joining data_selfreport_summary_subset and data_amp_summary_subset so that all participants have self-report data, + AMP data if available. which join is this? implement it.

Code
# data_self_reports_and_their_amp_data <- 

7.3.3 Practice 3

do the opposite: create ‘data_amp_data_and_their_self_reports’ by joining data_amp_summary_subset and data_selfreport_summary_subset so that all participants have AMP data, + self-report data if available. which join is this? implement it.

Code
# data_amp_data_and_their_self_reports <- 

7.3.4 Practice 4

create data_combined_2 by joining ‘data_combined’ and data_selfreport_summary_subset only unique_ids already present in data_combined are retained. which join is this? implement it.

Code
# data_combined_2 <- 

7.3.5 Practice 5

create ‘data_missing_ids’ which should list the unique_ids are missing from data_unique_id_subset but are present in at least one of data_age_gender_subset, data_amp_summary_subset, and data_selfreport_summary_subset. This will require two different joins. Which? Implement them.

Code
# data_missing_ids <-